/*
 * @Description:
 * @Version: 2.0
 * @Autor: wiz
 * @Date: 2023-08-08 14:06:48
 * @LastEditors: swc
 * @LastEditTime: 2024-06-18 16:56:19
 */

import { N_oSetupPanel } from '../config';
import {
  T_baseGrid,
  T_basePanel,
  T_baseTab,
  T_baseView,
  T_cBaseForm,
  T_dateNav,
  T_graph,
  T_multiForm,
  T_refBaseGrid,
  T_refComp,
  T_refGraph,
  T_reportChart,
  T_treeGrid,
  T_cloneBasePanel
} from './comps/types';

type I_graph = N_oSetupPanel.N_comps.I_graph;
type I_baseGrid = N_oSetupPanel.N_comps.I_baseGrid;
type I_baseTab = N_oSetupPanel.N_comps.I_baseTab;
type I_basePanel = N_oSetupPanel.N_comps.I_basePanel;
type I_cBaseForm = N_oSetupPanel.N_comps.I_cBaseForm;
type I_baseView = N_oSetupPanel.N_comps.I_baseView;
type I_treeGrid = N_oSetupPanel.N_comps.I_treeGrid;
type I_dateNav = N_oSetupPanel.N_comps.I_dateNav;
type I_compClass = N_oSetupPanel.N_comps.I_compClass;
type I_refComp = N_oSetupPanel.N_comps.I_refComp;
type I_multiForm = N_oSetupPanel.N_comps.I_multiForm;
type I_refGraph = N_oSetupPanel.N_comps.I_refGraph;
type I_refBaseGrid = N_oSetupPanel.N_comps.I_refBaseGrid;
type I_reportChart = N_oSetupPanel.N_comps.I_reportChart;
type I_cloneBasePanel = N_oSetupPanel.N_comps.I_cloneBasePanel;

export class T_compConf {
  public Graph: I_graph = null;

  public BaseGrid: I_baseGrid = null;

  public BaseTab: I_baseTab = null;

  public BasePanel: I_basePanel = null;

  public TreeGrid: I_treeGrid = null;

  public DateNav: I_dateNav = null;

  public cBaseForm: I_cBaseForm = null;

  public BaseView: I_baseView = null;

  public RefComp: I_refComp = null;

  public MultiForm: I_multiForm = null;

  public RefGraph: I_refGraph = null;

  public RefBaseGrid: I_refBaseGrid = null;

  public ReportChart: I_reportChart = null;

  public CloneBasePanel: I_cloneBasePanel = null;

  protected oSetupPanel: N_oSetupPanel.oSetupPanel = null;

  constructor(p: N_oSetupPanel.oSetupPanel) {
    this.BaseGrid = new T_baseGrid();
    this.Graph = new T_graph();
    this.TreeGrid = new T_treeGrid();
    this.DateNav = new T_dateNav();
    this.BaseTab = new T_baseTab();
    this.BasePanel = new T_basePanel();
    this.cBaseForm = new T_cBaseForm();
    this.BaseView = new T_baseView();
    this.RefComp = new T_refComp();
    this.MultiForm = new T_multiForm();
    this.RefGraph = new T_refGraph();
    this.RefBaseGrid = new T_refBaseGrid();
    this.ReportChart = new T_reportChart();
    this.CloneBasePanel = new T_cloneBasePanel();
    this.oSetupPanel = p;
  }

  protected getComponentList(): Array<
    N_oSetupPanel.N_comps.I_compItem<N_oSetupPanel.N_comps.I_compConfs>
  > {
    return [
      {
        moduleID: N_oSetupPanel.N_comps.COMP_MODULE_ID.BASE_GRID,
        name: N_oSetupPanel.N_comps.COMP_NAME.BASE_GRID,
        type: N_oSetupPanel.N_comps.COMP_TYPE.COMP,
        category: N_oSetupPanel.N_comps.COMP_CATEGORY.BASE_DATA,
        config: this.BaseGrid.getConf()
      },
      {
        moduleID: N_oSetupPanel.N_comps.COMP_MODULE_ID.BASE_TAB,
        name: N_oSetupPanel.N_comps.COMP_NAME.BASE_TAB,
        type: N_oSetupPanel.N_comps.COMP_TYPE.COMP,
        category: N_oSetupPanel.N_comps.COMP_CATEGORY.CONTAINER,
        config: this.BaseTab.getConf()
      },
      {
        moduleID: N_oSetupPanel.N_comps.COMP_MODULE_ID.TREE_GRID,
        name: N_oSetupPanel.N_comps.COMP_NAME.TREE_GRID,
        type: N_oSetupPanel.N_comps.COMP_TYPE.COMP,
        category: N_oSetupPanel.N_comps.COMP_CATEGORY.NAV,
        config: this.TreeGrid.getConf()
      },
      {
        moduleID: N_oSetupPanel.N_comps.COMP_MODULE_ID.DATE_NAV,
        name: N_oSetupPanel.N_comps.COMP_NAME.DATE_NAV,
        type: N_oSetupPanel.N_comps.COMP_TYPE.COMP,
        category: N_oSetupPanel.N_comps.COMP_CATEGORY.NAV,
        config: this.DateNav.getConf()
      },
      {
        moduleID: N_oSetupPanel.N_comps.COMP_MODULE_ID.BASE_PANEL,
        name: N_oSetupPanel.N_comps.COMP_NAME.BASE_PANEL,
        type: N_oSetupPanel.N_comps.COMP_TYPE.COMP,
        category: N_oSetupPanel.N_comps.COMP_CATEGORY.SINGLE_FUN,
        config: this.BasePanel.getConf()
      },

      {
        moduleID: N_oSetupPanel.N_comps.COMP_MODULE_ID.GRAPH,
        name: N_oSetupPanel.N_comps.COMP_NAME.GRAPH,
        type: N_oSetupPanel.N_comps.COMP_TYPE.COMP,
        category: N_oSetupPanel.N_comps.COMP_CATEGORY.GRAPH,
        config: this.Graph.getConf()
      },
      {
        moduleID: N_oSetupPanel.N_comps.COMP_MODULE_ID.BASE_FORM,
        name: N_oSetupPanel.N_comps.COMP_NAME.C_BASE_FORM,
        type: N_oSetupPanel.N_comps.COMP_TYPE.COMP,
        category: N_oSetupPanel.N_comps.COMP_CATEGORY.BASE_DATA,
        config: this.cBaseForm.getConf()
      },
      {
        moduleID: N_oSetupPanel.N_comps.COMP_MODULE_ID.BASE_VIEW,
        name: N_oSetupPanel.N_comps.COMP_NAME.BASE_VIEW,
        type: N_oSetupPanel.N_comps.COMP_TYPE.COMP,
        category: N_oSetupPanel.N_comps.COMP_CATEGORY.BASE_DATA,
        config: this.BaseView.getConf()
      },
      {
        moduleID: N_oSetupPanel.N_comps.COMP_MODULE_ID.REF_COMP,
        name: N_oSetupPanel.N_comps.COMP_NAME.REF_COMP,
        type: N_oSetupPanel.N_comps.COMP_TYPE.COMP,
        category: N_oSetupPanel.N_comps.COMP_CATEGORY.CONTAINER,
        config: this.RefComp.getConf()
      },
      {
        moduleID: N_oSetupPanel.N_comps.COMP_MODULE_ID.MULTI_FORM,
        name: N_oSetupPanel.N_comps.COMP_NAME.MULTI_FORM,
        type: N_oSetupPanel.N_comps.COMP_TYPE.COMP,
        category: N_oSetupPanel.N_comps.COMP_CATEGORY.CONTAINER,
        config: this.MultiForm.getConf()
      },
      {
        moduleID: N_oSetupPanel.N_comps.COMP_MODULE_ID.REF_GRAPH,
        name: N_oSetupPanel.N_comps.COMP_NAME.REF_GRAPH,
        type: N_oSetupPanel.N_comps.COMP_TYPE.COMP,
        category: N_oSetupPanel.N_comps.COMP_CATEGORY.GRAPH,
        config: this.RefGraph.getConf()
      },
      {
        moduleID: N_oSetupPanel.N_comps.COMP_MODULE_ID.REF_BASE_GRID,
        name: N_oSetupPanel.N_comps.COMP_NAME.REF_BASE_GRID,
        type: N_oSetupPanel.N_comps.COMP_TYPE.COMP,
        category: N_oSetupPanel.N_comps.COMP_CATEGORY.CONTAINER,
        config: this.RefBaseGrid.getConf()
      },
      {
        moduleID: N_oSetupPanel.N_comps.COMP_MODULE_ID.REPORT_CHART,
        name: N_oSetupPanel.N_comps.COMP_NAME.REPORT_CHART,
        type: N_oSetupPanel.N_comps.COMP_TYPE.COMP,
        category: N_oSetupPanel.N_comps.COMP_CATEGORY.CONTAINER,
        config: this.ReportChart.getConf()
      },
      {
        moduleID: N_oSetupPanel.N_comps.COMP_MODULE_ID.CLONE_BASE_PANEL,
        name: N_oSetupPanel.N_comps.COMP_NAME.CLONE_BASE_PANEL,
        type: N_oSetupPanel.N_comps.COMP_TYPE.COMP,
        category: N_oSetupPanel.N_comps.COMP_CATEGORY.CONTAINER,
        config: this.CloneBasePanel.getConf()
      }
    ];
  }

  public getCompClass(className: string): I_compClass {
    if (!className) {
      return null;
    }
    const name: string = className.toLowerCase();
    const baseGrid = N_oSetupPanel.N_comps.COMP_NAME.BASE_GRID;
    const basePanel = N_oSetupPanel.N_comps.COMP_NAME.BASE_PANEL;
    const baseView = N_oSetupPanel.N_comps.COMP_NAME.BASE_VIEW;
    const graph = N_oSetupPanel.N_comps.COMP_NAME.GRAPH;
    const cBaseForm = N_oSetupPanel.N_comps.COMP_NAME.C_BASE_FORM;
    const treeGrid = N_oSetupPanel.N_comps.COMP_NAME.TREE_GRID;
    const dateNav = N_oSetupPanel.N_comps.COMP_NAME.DATE_NAV;
    const refComp = N_oSetupPanel.N_comps.COMP_NAME.REF_COMP;
    const multiForm = N_oSetupPanel.N_comps.COMP_NAME.MULTI_FORM;
    const refGraph = N_oSetupPanel.N_comps.COMP_NAME.REF_GRAPH;
    const refBaseGrid = N_oSetupPanel.N_comps.COMP_NAME.REF_BASE_GRID;
    const reportChart = N_oSetupPanel.N_comps.COMP_NAME.REPORT_CHART;
    const baseTab = N_oSetupPanel.N_comps.COMP_NAME.BASE_TAB;
    const cloneBasePanel = N_oSetupPanel.N_comps.COMP_NAME.CLONE_BASE_PANEL;
    switch (name) {
      case baseGrid.toLowerCase():
        return this.BaseGrid;
      case baseTab.toLowerCase():
        return this.BaseTab;
      case basePanel.toLowerCase():
        return this.BasePanel;
      case baseView.toLowerCase():
        return this.BaseView;
      case graph.toLowerCase():
        return this.Graph;
      case cBaseForm.toLowerCase():
        return this.cBaseForm;
      case treeGrid.toLowerCase():
        return this.TreeGrid;
      case dateNav.toLowerCase():
        return this.DateNav;
      case refComp.toLowerCase():
        return this.RefComp;
      case multiForm.toLowerCase():
        return this.MultiForm;
      case refGraph.toLowerCase():
        return this.RefGraph;
      case refBaseGrid.toLowerCase():
        return this.RefBaseGrid;
      case reportChart.toLowerCase():
        return this.ReportChart;
      case cloneBasePanel.toLowerCase():
        return this.CloneBasePanel;

      default:
        return null;
    }
  }
}

export interface I_compConf extends T_compConf {}
